//
//  TNMemberDetailView.m
//  跑跑快销
//
//  Created by ylife on 14-4-30.
//  Copyright (c) 2014年 ylife. All rights reserved.
//

#import "TNMemberDetailView.h"
@implementation TNMemberDetailView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor lightTextColor]];
        // Initialization code
        [self createButtons];
        [self createCircle];
        [self createGoalView];
        [self createDetailView];
        [self hideDetailView];
    }
    return self;
}

//画百分比圆环
- (void)createCircle
{
    _circleView = [[YXGoalBar alloc]initWithFrame:CGRectMake(100,20, 120, 120)];
    [self addSubview:_circleView];
}

//画月目标量
- (void)createGoalView
{
    _goalButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [_goalButton setFrame:CGRectMake(60, 50 + _circleView.frame.size.height , 200, 60)];
    [_goalButton setBackgroundColor:[UIColor lightGrayColor]];
    [self addSubview:_goalButton];
}

//画底部按钮
- (void)createButtons
{
    _orderButton = [TNButton addRoundButtonWithTitle:@"订单管理" andButtonImageName:@"a.png" andFrame:CGRectMake(33 ,250, 62, 93)];
    [self addSubview:_orderButton];
    
    _markButton = [TNButton addRoundButtonWithTitle:@"签到记录" andButtonImageName:@"a.png" andFrame:CGRectMake(129 ,250 , 62, 93)];
    [self addSubview:_markButton];
    
    _teamButton = [TNButton addRoundButtonWithTitle:@"TA的团队" andButtonImageName:@"a.png" andFrame:CGRectMake(225 ,250 , 62, 93)];
    [self addSubview:_teamButton];
}

- (void)createDetailView
{
    UIView *detailView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 80)];
    [detailView setBackgroundColor:[UIColor whiteColor]];
//    detailView.layer.borderWidth = 2;    //设置边框线
    detailView.tag = 2;
    
    _headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 60, 60)];
    _headImageView.layer.masksToBounds = YES;
    _headImageView.layer.cornerRadius = 30;
    [detailView addSubview:_headImageView];
    
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(80, 15, 120, 20)];
    [lable setTextColor:[UIColor darkGrayColor]];
    [lable setText:@"联系电话:"];
    [detailView addSubview:lable];
    
    _phoneLable = [[UILabel alloc]initWithFrame:CGRectMake(80, 45, 150, 30)];
    [_phoneLable setFont:[UIFont systemFontOfSize:15]];
    [detailView addSubview:_phoneLable];
    
    _outButton = [[UIButton alloc]initWithFrame:CGRectMake(240, 10, 60, 60)];
    [_outButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [_outButton setTitle:@"踢出" forState:UIControlStateNormal];
    [detailView addSubview:_outButton];
    
    //画分割线
    UIImageView *line = [[UIImageView alloc]initWithFrame:CGRectMake(2, 78, 316, 2)];
    [line setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.1]];
    [detailView addSubview:line];
    
    [self addSubview:detailView];
}

- (void)showDetailView
{
    for (UIView *view in self.subviews) {
        if (view.tag == 2) {
            [view setHidden:NO];
        }
    }
}

- (void)hideDetailView
{
    for (UIView *view in self.subviews) {
        if (view.tag == 2) {
            [view setHidden:YES];
        }
    }
}

//其他控件下滑
- (void)lowAllViews
{
    for (UIView *view in self.subviews) {
        if (view.tag != 2) {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y + 80, view.frame.size.width, view.frame.size.height)];
        }
    }
}

- (void)highAllViews
{
    for (UIView *view in self.subviews) {
        if (view.tag != 2) {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y - 80, view.frame.size.width, view.frame.size.height )];
        }
    }

}

@end
